package com.yellowpage.ca.dao;

import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.yellowpage.ca.data.RoleFunction;
import com.yellowpage.white.dao.BaseDaoHibernateImpl;

public class RoleFunctionDaoImpl extends BaseDaoHibernateImpl<RoleFunction, Long>
		implements
			RoleFunctionDao {

	public RoleFunctionDaoImpl() {
		super(RoleFunction.class);
	}

	public List getRoleFunctionIdByRole(Long roleId, Long funcModuleId){
		String queryString = null;
		if(funcModuleId == null){
			queryString = "select rf.roleFunctionId from RoleFunction rf where rf.roleId = "
				+ roleId;
		}else{
			queryString = "select rf.roleFunctionId from RoleFunction rf, Function f" +
					" where rf.functionId = f.functionId " +
					"   and rf.roleId = " + roleId +
					"   and f.funcModuleId = " + funcModuleId;
		}		 
		return getHibernateTemplate().find(queryString);
	}

}
